local skill = fk.CreateSkill {
  name = "#zhao_tiger_tally_skill",
  attached_equip = "zhao_tiger_tally",
}

Fk:loadTranslationTable{
  ["#zhao_tiger_tally_skill"] = "赵帅符",
  ["#zhao_tiger_tally-choose"] = "赵帅符：你可以获得一名其他角色的一张牌",
}

skill:addEffect(fk.AfterCardsMove, {
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skill.name) and player:usedSkillTimes(skill.name, Player.HistoryTurn) == 0 then
      for _, move in ipairs(data) do
        if move.from == player and move.moveReason == fk.ReasonDiscard and move.proposer == player then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
              return table.find(player.room:getOtherPlayers(player, false), function (p)
                return not p:isNude()
              end)
            end
          end
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player, false), function (p)
      return not p:isNude()
    end)
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = targets,
      skill_name = skill.name,
      prompt = "#zhao_tiger_tally-choose",
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local card = room:askToChooseCard(player, {
      target = to,
      flag = "he",
      skill_name = skill.name,
    })
    room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, skill.name, nil, false, player)
  end,
})

return skill
